package com.example.bookmanagesystem.service;

import com.example.bookmanagesystem.dao.BookDao;
import com.example.bookmanagesystem.model.BookInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import java.util.List;

@Service// 将BookService对象交给SpringIoC容器
public class BookService {
    @Autowired// 依赖注入
    private BookDao bookDao;
    public List<BookInfo> getList() {
//        BookDao bookDao=new BookDao();
        // 从数据库中查询,先mock
        List<BookInfo> bookInfos=bookDao.mockData();// 搞假数据测试,学完数据库后,这里就可以改成数据库了
        for(BookInfo bookInfo:bookInfos){
            if(bookInfo.getStatus()==1) {
                bookInfo.setStatusCN("可借阅");
            } else {
                bookInfo.setStatusCN("不可借阅");
            }
        }
        return bookInfos;
    }
}
